<?php

//类别管理
namespace Home\Controller;
use Think\Controller;
class CategoryController  extends Controller {
 public function _initialize(){
       if(empty($_SESSION['empid'])){
    


           
 $this->error('页面加载中。。。',U('Login/Login'),1);
    
       }
       
    }
public function Classesadmin(){
    

$classes=M('CClass');
$cinfo=$classes->select();
$this->assign('cinfo',$cinfo);


$this->display();
    
}
public function Addclasses(){
   if(IS_AJAX){
      
        $class=M('CClass');
        $mas['classname']=I('post.classname');
        $ccount=$class->where($mas)->count();
        
        if($ccount>0){
            $data=3;
}else{
            
     
   $class->create();
   $add=$class->add();
        if($add){ 
            
           $data=0; 
        }    
        else{   $data=1; }
        }
        
        echo $data;
    }else{$this->display();}
        
    } 
 public function Classesxg(){
          $class=M('CClass');
   
   
   if(IS_AJAX){
     $mas['classname']=I('post.classname');
        $ccount=$class->where($mas)->count();
        
        if($ccount>0){
            $data=3;
}else{    
  $class->create();
  $updata=$class->save(); // 根据条件保存修改的数据    
  if($updata){
      
      $data=0;
  }else{
      
      $data=1;
}}
       echo $data;
       
   }else{
           
           $map['id']=I('get.id');
           $us=$class->where($map)->find();
           $this->assign('us',$us);
        $this->display();
        
   }    
     

 }   
    
    

public function Addressadmin(){
    


    

$area=M('CArea');
$dinfo=$area->select();
$this->assign('dinfo',$dinfo);
    $this->display();
    
}
public function Addaddress(){
 if(IS_AJAX){
      
       $area=M('CArea');
 $mas['areaname']=I('post.areaname');
 $ccount=$area->where($mas)->count();
  if($ccount>0){
      $data=3;
}else{
      $area->create();
   $add=$area->add();
        if($add){ 
            
           $data=0; 
        }    
  else{   $data=1; }
  }
        
        echo $data;
    }else{$this->display();}
        
    } 

    
public function Addressxg(){
   $area=M('CArea');
   
   
   if(IS_AJAX){
        $mas['areaname']=I('post.areaname');
 $ccount=$area->where($mas)->count();
  if($ccount>0){
      $data=3;
}else{
   $area->create();
  $updata= $area->save(); // 根据条件保存修改的数据    
  if($updata){
      
      $data=0;
  }else{
      
      $data=1;
}}
       echo $data;
       
   }else{
           
           $map['areaid']=I('get.id');
           $us= $area->where($map)->find();
           $this->assign('us',$us);
        $this->display();
        
   }       
    
}

public function Studentadmin(){
   
 
$student=M('SysDict');
$map['DICT_TYPE']=I('get.lbq');
   $sinfo= $student->where($map)->select();
    //  dump($student);
   $this->assign('sinfo',$sinfo);
   $this->display(); 
 
}
public function Addleibie(){
    
  if(IS_AJAX){
      
         $student=M('SysDict');
         $mas['DICT_NAME']=I('post.DICT_NAME');
         $ccount=$student->where($mas)->count();
         if($ccount>0){
             
             $data=3;
         }else{
   $student->create();
   $add=$student->add();
        if($add){ 
            
           $data=0; 
        }    
         else{   $data=1; }}
        
        echo $data;
    }else{$this->display();}
           
    
}
public function Leibiexg(){
    
 $student=M('SysDict');
   
   
   if(IS_AJAX){
         $mas['DICT_NAME']=I('post.DICT_NAME');
         $ccount=$student->where($mas)->count();
         if($ccount>0){
             
             $data=3;
         }else{
   $student->create();
  $updata= $student->save(); // 根据条件保存修改的数据    
  if($updata){
      
      $data=0;
  }else{
      
      $data=1;
         }}
       echo $data;
       
   }else{
           
           $map['id']=I('get.id');
           $us= $student->where($map)->find();
           $this->assign('us',$us);
        $this->display();
        
   }       
        
    
}
public function Curriculumadmin(){
    

//dump($qx);

    $this->display();
    
}
public function Teachingadmin(){
    

//dump($qx);

    $this->display();
}
public function del(){
        $id=I('get.id');
        $map['id']=$id;
        if(I('get.lb')=='classes'){
        $Classes=M('CClass');
    
        $del=$Classes->where($map)->delete();
        if($del){
            
          $this->success('删除成功');  
            
        }    else{
            
          $this->error('删除失败');  
            
        }
        }elseif(I('get.lb')=='address'){
              $area=M('CArea');
    $mas['areaid']=$id;
        $del=$area->where($mas)->delete();
        if($del){
            
          $this->success('删除成功');  
            
        }    else{
            
          $this->error('删除失败');  
            
        }   
            
        }elseif(I('get.lb')=='student'){
         $student=M('SysDict');
         $del=$student->where($map)->delete();
                 if($del){
            
          $this->success('删除成功');  
            
        }    else{
            
          $this->error('删除失败');  
            
        }   
        }
        
        
        
    }
    //put your code here
}
